This disclosure relates generally to the use of graphics processing units (GPUs). More particularly, but not by way of limitation, this disclosure relates to a technique for generating and using a compound shader object which, in accordance with this disclosure, provides a compiled/binary shader for a variety of different GPUs at run-time without the need for a central processing unit (CPU) compilation operation.
Shaders may be thought of as mini-programs that define or implement a specific graphic operation. Some shaders (pixel or vertex shaders) manipulate those elements that are displayed. Other shaders (fragment or texture shaders) manipulate the area between the vertices (e.g., a portion of the displayed object's surface). A source-code shader may be compiled to a binary file or module so that it can execute directly on one type of GPU (e.g., a particular brand/model of GPU). Alternatively, a shader may be used to generate a GPU-independent intermediate representation (IR) module. At run-time, a binary shader module may be executed directly by a GPU while an IR shader module must first be compiled for the specific GPU model to which it will be sent. As might be expected, a binary shader program may be executed at run-time much more quickly than an identical shader program in IR representation.
Unfortunately, a shader program compiled to binary for a first GPU type is not generally executable by a different type of GPU. In addition, as GPU architectures tend to evolve or change very rapidly, shader programs compiled to binary for one version of a GPU may not even execute on another version of that same GPU (at least not so that it takes advantage of the features or capabilities introduced in the newer version). It would be beneficial to allow an application using shader programs to execute properly across different versions of one GPU type and, even, across different GPU types.